/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MyClass;

import java.util.Random;
import javax.microedition.lcdui.Image;

/**
 *
 * @author HuuTai_it
 */
public class MainShip extends Ship {
    public boolean inV;
    public int autoMove(Ship s){
    return 0;
    }
    public MainShip (GameManagement gameMng, Image image) throws Exception {

        super(gameMng, image);
        boolean temp = true;
        inV = false;
        sType = 0;
        while(temp) {
            
            int x = Math.abs(gameMng.r.nextInt() % 10);
            int y = Math.abs(gameMng.r.nextInt() % 10);
            if(gameMng.element[x][y] == 0 && x > 1 && x < 8 && y > 1 && y < 8) {
                
                setPosition(x * 24, y * 24);
                gameMng.element[x][y] = 3;
                temp = false;
            }
        }
        a.setPosition(getX(), getY() );
        a.setVisible(false);
        b.setPosition(getX(), getY());
        b.setVisible(false);
    }
    public int fire()
    {
        
        if(!firing &&  !startMove)
        {
           return 0;
        }
        b.fire(); a.fire();
        if( a.isVisible() == false && b.isVisible() == false && firing)
        {
            firing = false;
            return 1;
        }
        return 0;
    }
    public int moves()
    {
        
        int res = 0;
        if(startMove)
        {
            //this.gameMng.control.move();
            switch(direction) 
                {            
                case DUP:res = moveUp(3);break;
                case DUPRIGHT:res = moveUpRight(3);break;
                case DRIGHT:res = moveRight(3);break;
                case DDOWNRIGHT:res = moveDownRight(3);break;
                case DDOWN:res = moveDown(3);break;
                case DDOWNLEFT:res = moveDownLeft(3);break;
                case DLEFT:res = moveLeft(3);break;
                case DUPLEFT:res = moveUpLeft(3);break;  
                }
        }
        return res;
    }
}
